package com.shopManager.contoller.shopAttr;


import com.shopAttr.bean.ShopAttr;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import  com.shopAttr.feign.ShopAttrFeign;
import org.springframework.web.bind.annotation.ResponseBody;
import shopBean.common.bean.RestResult;
import shopBean.common.utils.RestResultGenerator;

@Controller
@RequestMapping("/shopAttrManager/")
public class ShopAttrManagerController {

    @Autowired
    ShopAttrFeign shopAttrFeign;

    @RequestMapping("insert.shtml")
    @ResponseBody
    public RestResult insert(ShopAttr shopAttr) {
        if (StringUtils.isBlank(shopAttr.getName())) {
            return RestResultGenerator.genError("商品属性名称不能为空");
        }
        if (StringUtils.isBlank(shopAttr.getNote())) {
            return RestResultGenerator.genError("商品属性描述不能为空");
        }
        if (StringUtils.isBlank(shopAttr.getShopId())) {
            return RestResultGenerator.genError("商品id不能为空");
        }
        return this.shopAttrFeign.insert(shopAttr);
    }

    @RequestMapping("deleteById.shtml")
    @ResponseBody
    public RestResult insert(String id) {

        return this.shopAttrFeign.deleteById(id);
    }

    @RequestMapping("getByPId.shtml")
    @ResponseBody
    public RestResult getByPId(String id) {

        return null;
    }

}
